package com.wealth.scsj.p_app.view.activity;

import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.gigamole.navigationtabstrip.NavigationTabStrip;
import com.wealth.scsj.p_app.R;
import com.wealth.scsj.p_app.adapter.FragmentAdapter;
import com.wealth.scsj.p_app.utils.SkipUtils;
import com.wealth.scsj.p_app.view.fragment.BaseFragment;
import com.wealth.scsj.p_app.view.fragment.CancelFragment;
import com.wealth.scsj.p_app.view.fragment.FinishedFragment;
import com.wealth.scsj.p_app.view.fragment.GetFragment;
import com.wealth.scsj.p_app.view.fragment.NeverSendFragment;
import com.wealth.scsj.p_app.view.fragment.SendFragment;
import com.wealth.scsj.p_app.view.fragment.WaitFragment;

import java.util.ArrayList;

public class TotalOrderActivity extends BaseActivity {

    private NavigationTabStrip tabStrip;
    private ViewPager mViewPager;
    private FragmentAdapter mainFragmentAdapter;
    private String[] titles = {"已完成", "已取消", "无法送达"};

    @Override
    protected void createView(Bundle savedInstanceState) {
        setContentView(R.layout.activity_total_order);

        initToolbar();
        setToolbarTitle("全部订单");
        hasWhiteBack(true);

        initView();
        initListener();
        initData();

    }

    @Override
    protected void initView() {
        //TODO 暂去账单记录页面
        findViewById(R.id.toolbar_title).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SkipUtils.toWithDraw(TotalOrderActivity.this);

            }
        });

        intiNavigationBar();
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void initData() {

    }

    private void intiNavigationBar() {

        //顶部指示器
        tabStrip = findViewById(R.id.mediator_tab);
        mViewPager = findViewById(R.id.viewpager);
        mViewPager.setOffscreenPageLimit(3);
        ArrayList<BaseFragment> list = new ArrayList<>();

        FinishedFragment finishedFragment = new FinishedFragment();
        CancelFragment cancelFragment = new CancelFragment();
        NeverSendFragment neverSendFragment = new NeverSendFragment();

        list.add(finishedFragment);
        list.add(cancelFragment);
        list.add(neverSendFragment);


        mainFragmentAdapter = new FragmentAdapter(getSupportFragmentManager(), list);
        mViewPager.setAdapter(mainFragmentAdapter);
        tabStrip.setViewPager(mViewPager, 0);
        tabStrip.setTitles(titles);
        tabStrip.setStripType(NavigationTabStrip.StripType.LINE);
        tabStrip.setStripGravity(NavigationTabStrip.StripGravity.BOTTOM);
        tabStrip.setTabIndex(0, true);
    }
}
